import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import Cookies from '@/utils/auth'

export const useUserStore = defineStore('user', () => {
    // const qy_userid = ref(Cookies.get('qyUserId') || '')  // 企业微信成员id
    // const set_qy_userid = (data)=>{
    //     Cookies.set('qyUserId',data)
    //     qy_userid.value = data
    // }

    const userInfo = ref(JSON.parse(Cookies.get('userInfo') || '{}'))
    const setUserInfo = (obj)=>{
        Object.assign(userInfo.value,obj)
        Cookies.set('userInfo',JSON.stringify(userInfo.value))
        //userInfo.value = data
    }

    // // 缓存所有内部成员
    // const memberList = ref([])
    // const set_memberList = (data)=>{
    //     memberList.value = data || []
    // }

    return { 
        userInfo,
        setUserInfo
    }
})
